public class SingleLinkedList implements SinngleLinkedList{
    // 1、无头单向非循环链表实现
    static class ListNode{
        public int val;
        public ListNode next;

        public ListNode(int val) {
            this.val = val;
        }
    }
    public ListNode head;

    @Override
    public void addFirst(int data) {
        ListNode node=new ListNode(data);
        node.next=head;
        head=node;
    }

    @Override
    public void addLast(int data) {
        ListNode node=new ListNode(data);
        if(head==null){
            node.next=head;
            head=node;
            return;
        }
        ListNode cur=head;
        while(cur.next!=null){
            cur=cur.next;
        }
        cur.next=node;
    }

    @Override
    public boolean addIndex(int index, int data) {
        ListNode node=new ListNode(data);
        ListNode cur=head;

        return false;
    }

    @Override
    public boolean contains(int key) {
        ListNode node=new ListNode(key);
        ListNode cur=head;
        while(cur!=null){
            if(cur.val==key){
                return true;
            }
            cur=cur.next;
        }
        return false;
    }

    @Override
    public void remove(int key) {

    }

    @Override
    public void removeAllKey(int key) {

    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public void display() {

    }

    @Override
    public void clear() {

    }
}
